package Logic;

import java.security.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;

public class MD5
{
	public static String convert(String input)
	{
		String md5 = null;

		if (null == input)
		{
			return null;
		}

		try
		{
			MessageDigest digest = MessageDigest.getInstance("MD5");
			digest.update(input.getBytes(), 0, input.length());
			md5 = new BigInteger(1, digest.digest()).toString(16);
			
			while(md5.length() < 32)
			{
				md5 = "0" + md5;
			}
		}
		catch (NoSuchAlgorithmException e)
		{
			e.printStackTrace();
		}
		
		return md5;
	}
	
}
